﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GeostatisticalTool.Classes;

namespace GeostatisticalTool.Forms
{
    public partial class AnisotropyControl : UserControl
    {
        private AnisotropyValues anisotroy;
        public void SetAnisotropy(AnisotropyValues value)
        {
            this.anisotroy = value;
            if (value != null)
            {
                uxAngle2.Text = anisotroy.AngDip2.ToString();
                uxAngle.Text = anisotroy.Azimuth.ToString();
                uxTolerance.Text = anisotroy.Tolerance.ToString();
                uxBandwidth.Text = anisotroy.BandWidth.ToString();
            }
        }

        public AnisotropyControl()
        {
            InitializeComponent();
        }


        private void AnisotropyControl_Load(object sender, EventArgs e)
        {

        }

        private void uxApply_Click(object sender, EventArgs e)
        {

            anisotroy.SetDirectionParameters(Convert.ToDouble(uxBandwidth.Text), Convert.ToDouble(uxTolerance.Text), Convert.ToDouble(uxAngle.Text), Convert.ToDouble(uxAngle2.Text));
            //anisotroy.Azimuth  =  Convert.ToDouble(uxAngle.Text);
            //anisotroy.Tolerance = Convert.ToDouble(uxTolerance.Text);
            //anisotroy.BandWidth = Convert.ToDouble(uxBandwidth.Text);
        }

        private void uxAngle_TextChanged(object sender, EventArgs e)
        {
            try{
                Convert.ToDouble(uxAngle.Text);
                }
            catch{
                MessageBox.Show("Not numeric " + uxAngle.Text);
            }
        }

        private void uxAngle2_TextChanged(object sender, EventArgs e)
        {
            try
            {
                Convert.ToDouble(uxAngle2.Text);
            }
            catch
            {
                MessageBox.Show("Not numeric " + uxAngle2.Text);
            }
        }

        private void uxTolerance_TextChanged(object sender, EventArgs e)
        {
            try
            {
                Convert.ToDouble(uxTolerance.Text);
            }
            catch
            {
                MessageBox.Show("Not numeric " + uxTolerance.Text);
            }
        }

        private void uxBandwidth_TextChanged(object sender, EventArgs e)
        {
            try
            {
                Convert.ToDouble(uxBandwidth.Text);
            }
            catch
            {
                MessageBox.Show("Not numeric " + uxTolerance.Text);
            }
        }

    }
}
